package com.kx.game.center.common;

import com.kx.game.center.common.enums.IndexedEnum;
import com.kx.game.center.utils.EnumUtil;

import java.util.List;

public enum PlayerEnum implements IndexedEnum {
    LOGIN(1, "在线"),
    LOGOUT(2, "不在线"),;

    private final int index;

    private String param;

    PlayerEnum(int index, String param) {
        this.index = index;
        this.param = param;
    }

    /**
     * 按索引顺序存放的枚举数组
     */
    private static final List<PlayerEnum> indexes = IndexedEnum.IndexedEnumUtil
            .toIndexes(PlayerEnum.values());

    public static PlayerEnum indexOf(final int index) {
        return EnumUtil.valueOf(indexes, index);
    }

    public static PlayerEnum getMaxPlatformType() {
        for (int i = indexes.size() - 1; i > 0; i--) {
            if (indexes.get(i) != null)
                return indexes.get(i);
        }
        return null;
    }

    @Override
    public int getIndex() {
        return index;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public static List<PlayerEnum> getIndexes() {
        return indexes;
    }
}
